import { injectable } from "../../../../../app-core/inject";
import { Command } from "../../../../../app-core/mvcs/Command";
import { LoginModel } from "../../model/LoginModel";
import { LoginMediator } from "../../view/LoginMediator";

@injectable('LoginCommand')
export class LoginCommand extends Command {
    public execute(...args: any[]): void {
        let loginModel: LoginModel = this.injector.getInstance(LoginModel);

        let loginMediator: LoginMediator = <LoginMediator>this.injector.getValue('login_view')
        if (loginModel.loginState == 1) {
            loginModel.loginState = 0;
            loginMediator.logout();
        } else {
            loginModel.loginState = 1;
            loginMediator.login();
        }

    }

}